package thread;

public class Demo5 {
    //通过lambdab表达式（本质上时一个匿名函数，作为回调函数）创建线程
    //lambda表达式： () -> {}
    //该方法简单，较为推荐！
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
        while (true) {
            System.out.println("Hello Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    });

        t.start();
        while (true) {
            System.out.println("Hello main");
                Thread.sleep(1000);
            }
    }
}
